/*
 * @Author: fzs
 * @LastEditors: fzs
 * @Description: 封装http方法，基于fly封装，可以自定义请求拦截
 * @Date: 2019-04-11 10:35:00
 */

import uniFly from 'unifly';
import {baseApiUrl} from '../../config/base-config.js'
//基础路由
uniFly.baseUrl = baseApiUrl;
let project_token = 18031201;
uniFly.headers['project_token'] = project_token;
//全局请求超时时间
uniFly.timeOut = 20000
//自定义请求拦截
uniFly.requestInterceptors.success = function(request) {
  console.log('自定义请求拦截')
  //配置基本信息
  request.headers = uniFly.headers
  uni.showLoading()
  return request
}
uniFly.responseInterceptors.success = function(request) {
  console.log('自定义响应拦截',request)
  uni.hideLoading()
  return Promise.resolve(request.data)
}

const fly = uniFly;
export default fly